import re

import requests


class Client:
    @staticmethod
    def send_raw(server_info: str, text: str, text_format: str = ""):
        try:
            if text_format:
                text = text_format.replace("%p", text)
            res = re.findall("(.+):(.+)@(.*)", server_info)
            if not len(res) == 1:
                return
            result = res[0]
            url = f"http://{result[0]}:{result[1]}/terminal_log"
            token = result[2]
            requests.post(url, json={"token": token, "text": text}, timeout=3)
        except Exception:
            pass


if __name__ == '__main__':
    Client.send_raw("127.0.0.1:4999@123456", "1111111")
